home *** CD-ROM | disk | FTP | other *** search
- Option Explicit
-
- Type RECT
- Left As Integer
- Top As Integer
- Right As Integer
- Bottom As Integer
- End Type
-
- Global Const GWW_HINSTANCE = (-6)
-
-
- Declare Function GetFreeSpace& Lib "Kernel" (ByVal wFlags%)
- Declare Function GetFreeSystemResources% Lib "User" (ByVal fuSysResource%)
- Declare Function GetWinFlags& Lib "Kernel" ()
- Declare Function GetVersion& Lib "Kernel" ()
- Declare Function GetModuleHandle% Lib "Kernel" (ByVal lpModuleName$)
- Declare Function LoadString% Lib "User" (ByVal hInstance%, ByVal wID%, ByVal lpBuffer$, ByVal nBufferMax%)
- Declare Function SelectObject% Lib "GDI" (ByVal hDC%, ByVal hObject%)
- Declare Function CreateSolidBrush% Lib "GDI" (ByVal crColor&)
- Declare Function DeleteObject% Lib "GDI" (ByVal hObject%)
- Declare Function GetDC% Lib "User" (ByVal hWnd%)
- Declare Sub GetWindowRect Lib "User" (ByVal hWnd%, lpRect As RECT)
- Declare Function Rectangle% Lib "GDI" (ByVal hDC%, ByVal X1%, ByVal Y1%, ByVal X2%, ByVal Y2%)
- Declare Function ReleaseDC% Lib "User" (ByVal hWnd%, ByVal hDC%)
- Declare Function GetWindowsDirectory% Lib "Kernel" (ByVal lpBuffer$, ByVal nSize%)
- Declare Function GetSystemDirectory% Lib "Kernel" (ByVal lpBuffer$, ByVal nSize%)
- Declare Function GetCurrentTask% Lib "Kernel" ()
- Declare Function GetModuleFileName% Lib "Kernel" (ByVal hModule%, ByVal lpFilename$, ByVal nSize%)
- Declare Function GetWindowWord% Lib "User" (ByVal hWnd%, ByVal nIndex%)
- Declare Function ExtractIcon% Lib "Shell" (ByVal hInst%, ByVal FileName$, ByVal iIcon%)
- Declare Function DestroyIcon% Lib "user" (ByVal hIcon%)
- Declare Function GlobalSize& Lib "kernel" (ByVal hGlobal%)
- Declare Function GlobalLock& Lib "kernel" (ByVal hGlobal%)
- Declare Function GlobalUnlock% Lib "kernel" (ByVal hGlobal%)
- Declare Sub hmemcpy Lib "kernel" (ByVal hpDest&, ByVal hpSource&, ByVal cbCopy&)
-
- Function AppIcon2Pic% (Pic As PictureBox)
-
- Dim hIcon%
- Dim Rc%
- Dim hInst%
-
- hInst% = GetWindowWord%(Pic.hWnd, GWW_HINSTANCE)
-
- hIcon% = ExtractIcon%(hInst%, ExeName$(hInst%), 0)
- If hIcon% Then
- AppIcon2Pic% = CopyIcon%(hIcon%, (Pic.Picture))
- Rc% = DestroyIcon%(hIcon%)
- End If
-
- End Function
-
- Function CopyIcon% (hSource%, hDest%)
-
- '~~~~~ Copies the icon from *hSource to *hDest, provided the
- '~~~~~ memory blocks at *hSource and *hDest are the same size.
- '~~~~~ hSource and hDest are Handles to Icons
-
- Dim sizeSource&, sizeDest&
- Dim fpSource&, fpDest&
- Dim Rc%
-
- CopyIcon% = False
-
- ' get size of memory blocks
- sizeSource& = GlobalSize&(hSource%)
- sizeDest& = GlobalSize&(hDest%)
-
- If sizeDest& <> sizeSource& Then
- If sizeSource& <> 288 Then ' not a monochrome icon
- Exit Function
- End If
- End If
-
- ' lock memory and get far pointers to Source & Destination
- fpSource& = GlobalLock&(hSource%)
- fpDest& = GlobalLock&(hDest%)
-
- ' copy Source to Destination
- hmemcpy fpDest&, fpSource&, sizeSource&
-
- ' unlock memory
- Rc% = GlobalUnlock%(hDest)
- Rc% = GlobalUnlock%(hSource)
-
- CopyIcon% = True
-
- End Function
-
- Function ExeName$ (hInst%)
-
- Dim Temp$
- Dim NameLen%
-
- Temp$ = String(255, Chr$(0))
- NameLen% = GetModuleFileName%(hInst%, Temp$, Len(Temp$))
- If NameLen% Then
- ExeName$ = Left$(Temp$, NameLen%)
- Else
- ExeName$ = "<Unknown>"
- End If
-
- End Function
-
- Function FormatLong$ (TheNum&)
-
- Dim TheStr$
-
- TheStr$ = Space$(11)
-
- RSet TheStr$ = Format$(TheNum&, "###,###,##0")
-
- FormatLong$ = TheStr$
-
- End Function
-
- Sub FormCenter (Frm As Form)
-
- Dim TheTop%, TheLeft%
-
- TheTop% = (Screen.Height - Frm.Height) / 2
- TheLeft% = (Screen.Width - Frm.Width) / 2
-
- Frm.Move TheLeft%, TheTop%
-
- End Sub
-
- Sub FormExplode (Frm As Form)
-
- ' "explodes" a form by drawing successively larger rectangles,
- ' using the form's background color, to fill the form area.
- ' Should be called from the Form_Load event procedure.
-
- ' Number of steps to use in expanding the rectangle. More steps
- ' result in a slower but smoother "explosion."
-
- Const STEPS = 60
-
- Dim FormWidth%
- Dim FormHeight%
- Dim Count%
- Dim X%
- Dim Y%
- Dim XStep%
- Dim YStep%
- Dim hDCScreen%
- Dim hBrush%
- Dim MyRect As RECT
- Dim di%
- Dim ret%
-
- ' Get the form's coordinates and detemine its height and width.
-
- Call GetWindowRect(Frm.hWnd, MyRect)
-
- FormWidth% = MyRect.Right% - MyRect.Left%
- FormHeight% = MyRect.Bottom% - MyRect.Top%
-
- ' Get the screen's device context.
-
- hDCScreen% = GetDC(0)
-
- ' Create a solid brush that uses the form's background color.
-
- hBrush% = CreateSolidBrush%(Frm.BackColor)
- di% = SelectObject%(hDCScreen%, hBrush%)
-
- ' Draw successively larger rectangles until the form's
- ' entire area is filled.
-
- For Count% = 1 To STEPS
- XStep% = FormWidth * (Count% / STEPS)
- YStep% = FormHeight * (Count% / STEPS)
- X% = MyRect.Left% + (FormWidth - XStep%) / 2
- Y% = MyRect.Top% + (FormHeight - YStep%) / 2
- ret% = Rectangle%(hDCScreen%, X%, Y%, X% + XStep%, Y% + YStep%)
- Next Count%
-
- ' Release the device context and brush, and display the form.
-
- di% = ReleaseDC%(0, hDCScreen%)
- ret% = DeleteObject%(hBrush%)
-
- End Sub
-
- Sub main ()
-
- Dim ProductName$
- Dim ProductVersion$
- Dim Copyright$
-
- ProductName$ = "AboutWin"
- ProductVersion$ = "1.00a"
- Copyright$ = "Copyright ⌐ 1994 by XYZ."
-
- Load frmAbout
- frmAbout!lblVersion.Caption = ProductName$ & " Version " & ProductVersion$ & " is licensed to:"
- frmAbout!lblCopyright.Caption = Copyright$
- Call FormExplode(frmAbout)
- frmAbout.Show
-
- End Sub
-
- Sub ShowAbout (ProductId$, Copyright$)
-
- Load frmAbout
- Call FormExplode(frmAbout)
- frmAbout.Show
-
- End Sub
-
- Function SysDir$ ()
-
- Dim Temp$
- Dim NameLen%
-
- Temp$ = String(255, Chr$(0))
- NameLen% = GetSystemDirectory%(Temp$, Len(Temp$))
- If NameLen% Then
- SysDir$ = Left$(Temp$, NameLen%)
- Else
- SysDir$ = "<Unknown>"
- End If
-
- End Function
-
- Function WinDir$ ()
-
- Dim Temp$
- Dim NameLen%
-
- Temp$ = String(255, Chr$(0))
- NameLen% = GetWindowsDirectory%(Temp$, Len(Temp$))
- If NameLen% Then
- WinDir$ = Left$(Temp$, NameLen%)
- Else
- WinDir$ = "<Unknown>"
- End If
-
- End Function
-
-